Regression tests for #5201
authorAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 19 Mar 2018 20:13:04 +0000 (23:13 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Mon, 19 Mar 2018 20:51:49 +0000 (23:51 +0300)
Better safe than sorry!

Cargo.toml
tests/testsuite/cargo_command.rs

index 68d29b148930a5a7d51c7e0a9dd7e5d244611b31..ab89abfa6fd95be6d31bc807d9b301147624d0f0 100644 (file)
@@ -53,7 +53,7 @@ tempdir = "0.3"
 termcolor = "0.3"
 toml = "0.4"
 url = "1.1"
-clap = "2.27.0"
+clap = "2.31.2"
 
 # Not actually needed right now but required to make sure that rls/cargo build
 # with the same set of features in rust-lang/rust
index d0574a6d8aa0af374ecc132ab6af599b1bc63f01..7b180ec7a09bc4b1dd3c57fd157612bd3262818c 100644 (file)
@@ -7,6 +7,7 @@ use std::str;
 use cargo;
 use cargotest::cargo_process;
 use cargotest::support::paths::{self, CargoPathExt};
+use cargotest::support::registry::Package;
 use cargotest::support::{basic_bin_manifest, execs, project, Project};
 use hamcrest::{assert_that, existing_file};
 
@@ -115,18 +116,47 @@ fn list_command_resolves_symlinks() {
 
 #[test]
 fn find_closest_biuld_to_build() {
-    let mut pr = cargo_process();
-    pr.arg("biuld");
-
     assert_that(
-        pr,
-        execs().with_status(1).with_stderr_contains(
+        cargo_process().arg("biuld"),
+        execs().with_status(101).with_stderr_contains(
             "\
-error: The subcommand 'biuld' wasn't recognized
-<tab>Did you mean 'build'?
+error: no such subcommand: `biuld`
+
+<tab>Did you mean `build`?
 ",
         ),
     );
+
+    // But, if we actually have `biuld`, it must work!
+    // https://github.com/rust-lang/cargo/issues/5201
+    Package::new("cargo-biuld", "1.0.0")
+        .file(
+            "src/main.rs",
+            r#"
+            fn main() {
+                println!("Similar, but not identical to, build");
+            }
+        "#,
+        )
+        .publish();
+
+    assert_that(
+        cargo_process().arg("install").arg("cargo-biuld"),
+        execs().with_status(0),
+    );
+    assert_that(
+        cargo_process().arg("biuld"),
+        execs()
+            .with_status(0)
+            .with_stdout("Similar, but not identical to, build\n"),
+    );
+    assert_that(
+        cargo_process().arg("--list"),
+        execs()
+            .with_status(0)
+            .with_stdout_contains("    build\n")
+            .with_stdout_contains("    biuld\n"),
+    );
 }
 
 // if a subcommand is more than 3 edit distance away, we don't make a suggestion